package lib

func init() {
	Probs = append(Probs, Problem{
		Num:         242,
		Discription: "异位词判断",
		Level:       1,
		Labels: map[string]int{
			"哈希表": 1,
			"字符串": 1,
		},
	})
}

func IsAnagram(s string, t string) bool {
	if len(s) != len(t) {
		return false
	}

	//用rune的遍历形式解决一个字符可能对应多个字节的情况
	chMap := make(map[rune]int, 0)
	for _, ch := range s {
		chMap[ch]++
	}
	for _, ch := range t {
		chMap[ch]--
		if chMap[ch] < 0 {
			return false
		}
	}

	return true
}
